﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RoekScissorPaper
{
    public partial class Form1 : Form
    {
        private int playerWin = 0;
        private int computerWin = 0;
        public Form1()
        {
            InitializeComponent();
        }

        private void btnStone_Click(object sender, EventArgs e)
        {
            //玩家出石头
            var fistStr = "石头";
            Play(fistStr);
            
        }

        private void btnScissors_Click(object sender, EventArgs e)
        {
            var fistStr = "剪刀";
            Play(fistStr);

        }

        private void btnCloth_Click(object sender, EventArgs e)
        {
            var fistStr = "布";
            Play(fistStr);

        }
        //游戏调用
        private void Play(string fistStr)
        {
            lblPlayer.Text = fistStr;
            var play = new Player();
            var enumPlayer = play.ShowFist(fistStr);

            //电脑出拳
            var com = new Computer();
            var enumCom = com.ShowFist();
            lblComouter.Text = com.Fist.ToString();

            //裁判出场
            
            var enumResult = Judge.GetResult((int)enumPlayer, (int)enumCom);

            //胜利计数
            if (enumResult == EnumResult.玩家赢)
            {
                int num = Convert.ToInt32(lblPlayerScore.Text);
                num++;
                lblPlayerScore.Text = Convert.ToString(num);
            }
            else if(enumResult == EnumResult.电脑赢)
            {
                int num = Convert.ToInt32(lblComputerScore.Text);
                num++;
                lblComputerScore.Text = Convert.ToString(num);
            }
            lblResult.Text = enumResult.ToString();
                if (lblPlayerScore.Text == "10" || lblComputerScore.Text == "10")
                    lblResult.Text = enumResult.ToString() + "了10局";

             
            
        }
    }
}
